package cn.edu.ctbu.studentweb.controller;

import cn.edu.ctbu.studentweb.domain.Student;
import cn.edu.ctbu.studentweb.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/student")
public class StudentController {
    @Autowired
    private StudentService studentService;

    @RequestMapping("/list")
    public String list(Model model){
        List<Student> students = studentService.findAll();
        model.addAttribute("students", students);
        return "student/list";
    }
}
